<?php
/**
 * PProcess class
 * This class is made to implement process.
 *
 * @author Patrice Ferlet <metal3d@copix.org> 
 * @package core
 * @license http://opensource.org/licenses/lgpl-3.0.html GNU Lesser General Public License Version 3.0 (LGPLv3)
*/


class PProcess {

    public function execute(PActionReturn $actionReturn){
        switch ($actionReturn->code){
            case PActionReturn::REDIRECT:
                header('Location: '.$actionReturn->datas);
                break;
            case PActionReturn::NONE:
                break;
            case PActionReturn::DISPLAY:
                //fetch main template and assignate coordination vars
                $themedir = _config()->get('root/paths')->name('theme@path');
                $maintpl  = _config()->get('root/project')->name('main@template');

                $tpl = new PTemplate();
                $tpl->assignXMLStruct(_config()->get('root/project/templatevars'),$actionReturn->datas);

                echo $tpl->fetch($themedir.'/'.$maintpl,FALSE);

                break;
            default:
                Debug::log("Nothing appends","display");
                break;
        }
    }

}

